import { createSlice } from "@reduxjs/toolkit";

const counterStore = createSlice({
  name: "counter",
  initialState: {
    count: 0,
  },
  reducers: {
    add(state,action) {
      state.count = state.count + action.payload.num
    },
    del(state,action) {
      state.count = state.count - action.payload.num
    },
  },
});

const { add, del } = counterStore.actions;

const reducer = counterStore.reducer;

export { add, del };

export default reducer;
